﻿function extend(subClass, superClass) {
    var f = function() {};
    f.prototype = superClass.prototype;
    subClass.prototype = new f();
    subClass.prototype.constructor = subClass;

    subClass.superclass = superClass.prototype;
    if (superClass.prototype.constructor == Object.prototype.constructor) {
        superClass.prototype.constructor = superClass;
    }
};

var override = function(f, newCode) {
    if (!f)
        return null;

    if (!newCode)
        return f;
    var proxied = f;
    f = function() {
        var ret = newCode();
        proxied.apply(this, arguments);

        return ret;
    };
    return f;
};